<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['slideshow']) && ($_SESSION['slideshow'] <= 0))) {
	$this->_redirect(HOST_BACKEND);
}
$arrParams 		= $objRequest->getParams();
$intAction 		= isset($arrParams['paction']) ? $arrParams['paction'] : 0;
$arrAlbumId 	= isset($arrParams['palbumid']) ? $arrParams['palbumid'] : null;
$strError		= '';
$strMsg			= '';

if($intAction && $arrAlbumId) {	
	$objSlideshow	= new Slideshow();
	switch ($intAction) {
		case 1: // active
			if(isset($_SESSION['slideshow']) && ($_SESSION['slideshow']&1<<5) != 0) {							
				foreach($arrAlbumId as $row) {
					$objSlideshow->updateStatusAlbum($AppUI->id,$row,1,32);
				}
				$strMsg		= $arrMessage['slideshow_status'];
			}
			else {
				$strError	= $arrError['noperm_slideshow_status'];
			}
			break;
		case 2: // delete
			if(isset($_SESSION['slideshow']) && ($_SESSION['slideshow']&1<<3) != 0) {				
				foreach($arrAlbumId as $row) {					
					$objSlideshow->updateStatusAlbum($AppUI->id,$row,2,8);
				}
				$strMsg		= $arrMessage['slideshow_delete'];
			}
			else {
				$strError	= $arrError['noperm_slideshow_delete'];
			}
			break;
		case 3:
			if(isset($_SESSION['slideshow']) && ($_SESSION['slideshow']&1<<4) != 0) {	
				foreach($arrAlbumId as $row) {
					$objSlideshow->updateStatusAlbum($AppUI->id,$row,0,16);
				}
				$strMsg		= $arrMessage['slideshow_status'];
			}
			else {
				$strError	= $arrError['noperm_slideshow_status'];
			}
			break;		
	}
} else {
	$strError	= $arrError['nodata_act'];
}
if($strError == '') {
	Ecore_Function::setMsg($strMsg);
} else {
	Ecore_Function::setError($strError);	
}
$this->_redirect(isset($_SESSION[SESSION_BACKURL]) ? $_SESSION[SESSION_BACKURL] : HOST_BACKEND);